﻿<!DOCTYPE html>
<html>
<head>
    <title>CGI</title>
</head>
<body>
    <h1>Our Page</h1>
    <script>
        //01

        var project = {
            name: 'Project Cigna'
        };

        console.log(project.foo());


        //02
        //here we didn't declared toString() function within project object. it's available in prototype
        /*
        var project = {
            name: 'Project Cigna'
        };
        console.log(project.toString());
        */

        //03
        //Object (capital o) is a global constructor function in JS and it has a prototype
        //Object.prototype do exist as an object
        /*
        console.log(typeof Object.prototype);

        //.toString function exist in Object.prototype and not in Object
        console.log(typeof Object.prototype.toString);
         */

        //04
        //prototype is more even internal JS field and we don't get access to it
        //we get undefined here
        /*
        var project = {
            name: 'Project Cigna'
        };
        console.log(project.prototype);

        //by dunder proto (__proto__) we have access project prototype
        var project = {
            name: 'Project Cigna'
        };

        console.log(typeof project.__proto__);
        */

        //05
        //Objcet is a constructor function, hence it does have valid prototype
        //here result is identically equal
        //when we create a object with JSON notation or a simple new Object call, that object prototype set to Object.prototype, inheritance
        //every object has a prototype attached
        /*
        var project = {
            name: 'Project Cigna'
        };
        console.log(project.__proto__ === Object.prototype);
        */
    </script>
</body>
</html>